home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / newapa.bst < prev    next >
Text File  |  1992-07-19  |  28KB  |  1,469 lines

  1. %$$$ newapa.bst $$$
  2. % BibTeX `newapa' style file for BibTeX version 0.99c, LaTeX version 2.09
  3. % Place it in a file called newapa.bst in the BibTeX search path.  
  4. %(Placing it in the same directory as the LaTeX document should also work.)
  5. % Support for named citations is provided by named.sty
  6.  
  7. % This version was made by modifying the master file made by
  8. % Oren Patashnik (PATASHNIK@SCORE.STANFORD.EDU), and the 'named' BibTeX
  9. % style of Peter F. Patel-Schneider.
  10.  
  11. % Copyright (C) 1985, all rights reserved.
  12. % Copying of this file is authorized only if either
  13. % (1) you make absolutely no changes to your copy, including name, or
  14. % (2) if you do make changes, you name it something other than 'newapa.bst'.
  15. % There are undoubtably bugs in this style.  If you make bug fixes,
  16. % improvements, etc.  please let me know.  My e-mail address is:
  17. %    spencer@cgrg.ohio.state.edu or 71160.3141@compuserve.com
  18. %
  19. % This style was made from 'plain.bst', 'named.bst', and 'apalike.bst', 
  20. % with lots of tweaking to make it look like APA style, along with tips 
  21. % from Young Ryu and Brian Reiser's modifications of 'apalike.bst'.
  22. %
  23. %   Citation format: (author-last-name, year)
  24. %             (author-last-name and author-last-name, year)
  25. %             (author-last-name {\em et al.}, year)
  26. %             (author-last-name)
  27. %             (author-last-name and author-last-name)
  28. %             (author-last-name {\em et al.})
  29. %             (year)
  30. %
  31. %   Reference list ordering: alphabetical by author or whatever passes
  32. %    for author in the absence of one.
  33. %
  34. % This BibTeX style has support for abbreviated author lists and for
  35. %    year-only citations.  This is done by having the citations
  36. %    actually look like
  37. %
  38. %    \citeauthoryear{full-author-info}{abbrev-author-info}{year}
  39. %
  40. % The LaTeX style has to have the following (or similar)
  41. %
  42. %     \let\@internalcite\cite
  43. %     \def\fullcite{\def\citeauthoryear##1##2##3{##1, ##3}\@internalcite}
  44. %     \def\fullciteA{\def\citeauthoryear##1##2##3{##1}\@internalcite}
  45. %     \def\shortcite{\def\citeauthoryear##1##2##3{##2, ##3}\@internalcite}
  46. %     \def\shortciteA{\def\citeauthoryear##1##2##3{##2}\@internalcite}
  47. %     \def\citeyear{\def\citeauthoryear##1##2##3{##3}\@internalcite}
  48. %
  49.  
  50. ENTRY
  51.   { address
  52.     author
  53.     booktitle
  54.     chapter
  55.     edition
  56.     editor
  57.     howpublished
  58.     institution
  59.     journal
  60.     key
  61. %   month
  62.     note
  63.     number
  64.     organization
  65.     pages
  66.     publisher
  67.     school
  68.     series
  69.     title
  70.     type
  71.     volume
  72.     year
  73.   }
  74.   {}
  75.   { label extra.label sort.label }
  76.  
  77. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  78.  
  79. FUNCTION {init.state.consts}
  80. { #0 'before.all :=
  81.   #1 'mid.sentence :=
  82.   #2 'after.sentence :=
  83.   #3 'after.block :=
  84. }
  85.  
  86. STRINGS { s t u }
  87.  
  88. FUNCTION {output.nonnull}
  89. { 's :=
  90.   output.state mid.sentence =
  91.     { ", " * write$ }
  92.     { output.state after.block =
  93.     { add.period$ write$
  94.       newline$
  95.       "\newblock " write$
  96.     }
  97.     { output.state before.all =
  98.         'write$
  99.         { add.period$ " " * write$ }
  100.       if$
  101.     }
  102.       if$
  103.       mid.sentence 'output.state :=
  104.     }
  105.   if$
  106.   s
  107. }
  108.  
  109. FUNCTION {special.output.nonnull}
  110. { 's :=
  111.   output.state mid.sentence =
  112.     { "  " * write$ }
  113.     { output.state after.block =
  114.         { ": " write$
  115.           newline$
  116.           "\newblock " write$
  117.         }
  118.         { output.state before.all =
  119.             'write$
  120.             { ": " * write$
  121.             }
  122.           if$
  123.         }
  124.       if$
  125.       mid.sentence 'output.state :=
  126.     }
  127.   if$
  128.   s
  129. }
  130.  
  131. FUNCTION {output.nonnull.colon}
  132. { 's :=
  133.   output.state mid.sentence =
  134.     { ": " * write$ }
  135.     { output.state after.block =
  136.     { add.period$ write$
  137.       newline$
  138.       "\newblock " write$
  139.     }
  140.     { output.state before.all =
  141.         'write$
  142.         { add.period$ " " * write$ }
  143.       if$
  144.     }
  145.       if$
  146.       mid.sentence 'output.state :=
  147.     }
  148.   if$
  149.   s
  150. }
  151.  
  152. FUNCTION {output.nonnull.space}
  153. { 's :=
  154.   output.state mid.sentence =
  155.     { "\ " * write$ }
  156.     { output.state after.block =
  157.     { add.period$ write$
  158.       newline$
  159.       "\newblock " write$
  160.     }
  161.     { output.state before.all =
  162.         'write$
  163.         { add.period$ " " * write$ }
  164.       if$
  165.     }
  166.       if$
  167.       mid.sentence 'output.state :=
  168.     }
  169.   if$
  170.   s
  171. }
  172.  
  173. FUNCTION {special.output}
  174. { duplicate$ empty$
  175.     'pop$
  176.     'special.output.nonnull
  177.   if$
  178. }
  179.  
  180. FUNCTION {output}
  181. { duplicate$ empty$
  182.     'pop$
  183.     'output.nonnull
  184.   if$
  185. }
  186.  
  187. FUNCTION {output.check}
  188. { 't :=
  189.   duplicate$ empty$
  190.     { pop$ "empty " t * " in " * cite$ * warning$ }
  191.     'output.nonnull
  192.   if$
  193. }
  194.  
  195. FUNCTION {output.check.colon}
  196. { 't :=
  197.   duplicate$ empty$
  198.     { pop$ "empty " t * " in " * cite$ * warning$ }
  199.     'output.nonnull.colon
  200.   if$
  201. }
  202.  
  203. FUNCTION {output.check.space}
  204. { 't :=
  205.   duplicate$ empty$
  206.     { pop$ "empty " t * " in " * cite$ * warning$ }
  207.     'output.nonnull.space
  208.   if$
  209. }
  210.  
  211. FUNCTION {output.year.check}
  212. { year empty$
  213.      { "empty year in " cite$ * warning$ }
  214.      { write$
  215.         " (" year * extra.label * ")" *
  216.         mid.sentence 'output.state :=
  217.      }
  218.   if$
  219. }
  220.  
  221. FUNCTION {output.bibitem}
  222. { newline$
  223.  
  224.   "\bibitem[" write$
  225.   label write$
  226.   "]{" write$
  227.  
  228.   cite$ write$
  229.   "}" write$
  230.   newline$
  231.   ""
  232.   before.all 'output.state :=
  233. }
  234.  
  235. FUNCTION {fin.entry}
  236. { add.period$
  237.   write$
  238.   newline$
  239. }
  240.  
  241. FUNCTION {new.block}
  242. { output.state before.all =
  243.     'skip$
  244.     { after.block 'output.state := }
  245.   if$
  246. }
  247.  
  248. FUNCTION {new.sentence}
  249. { output.state after.block =
  250.     'skip$
  251.     { output.state before.all =
  252.     'skip$
  253.     { after.sentence 'output.state := }
  254.       if$
  255.     }
  256.   if$
  257. }
  258.  
  259. FUNCTION {not}
  260. {   { #0 }
  261.     { #1 }
  262.   if$
  263. }
  264.  
  265. FUNCTION {and}
  266. {   'skip$
  267.     { pop$ #0 }
  268.   if$
  269. }
  270.  
  271. FUNCTION {or}
  272. {   { pop$ #1 }
  273.     'skip$
  274.   if$
  275. }
  276.  
  277. FUNCTION {new.block.checka}
  278. { empty$
  279.     'skip$
  280.     'new.block
  281.   if$
  282. }
  283.  
  284. FUNCTION {new.block.checkb}
  285. { empty$
  286.   swap$ empty$
  287.   and
  288.     'skip$
  289.     'new.block
  290.   if$
  291. }
  292.  
  293. FUNCTION {new.sentence.checka}
  294. { empty$
  295.     'skip$
  296.     'new.sentence
  297.   if$
  298. }
  299.  
  300. FUNCTION {new.sentence.checkb}
  301. { empty$
  302.   swap$ empty$
  303.   and
  304.     'skip$
  305.     'new.sentence
  306.   if$
  307. }
  308.  
  309. FUNCTION {field.or.null}
  310. { duplicate$ empty$
  311.     { pop$ "" }
  312.     'skip$
  313.   if$
  314. }
  315.  
  316. FUNCTION {underline}
  317. { duplicate$ empty$
  318.   { pop$ "" }
  319.   { "\underline{" swap$ * "}" * }
  320.   if$
  321. }
  322.  
  323. FUNCTION {emphasize}
  324. { duplicate$ empty$
  325.     { pop$ "" }
  326.     { "{\em " swap$ * "}" * }
  327.   if$
  328. }
  329.  
  330. FUNCTION {emphasize.space}
  331. { duplicate$ empty$
  332.     { pop$ "" }
  333.     { "{\em " swap$ * "\/}" * }
  334.   if$
  335. }
  336.  
  337. INTEGERS { nameptr namesleft numnames }
  338.  
  339. FUNCTION {format.names}
  340. { 's :=
  341.   #1 'nameptr :=               % nameptr = 1;
  342.   s num.names$ 'numnames :=    % numnames = num.name$(s);
  343.   numnames 'namesleft :=
  344.     { namesleft #0 > }
  345.  
  346.     { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=
  347.  
  348.       nameptr #1 >
  349.         { namesleft #1 >
  350.               { ", " * t * }
  351.                { numnames #2 >
  352.                     { "," * }
  353.                     'skip$
  354.                   if$
  355.                   t "others" =
  356.                         { " et~al." * }
  357. %                       { " and " * t * }
  358. %                       { ", \& " * t * }
  359.                         { " \& " * t * }
  360.                       if$
  361.                 }
  362.                if$
  363.              }
  364.             't
  365.         if$
  366.         nameptr #1 + 'nameptr :=          % nameptr += 1;
  367.         namesleft #1 - 'namesleft :=      % namesleft =- 1;
  368.     }
  369.   while$
  370. }
  371.  
  372. FUNCTION {format.names.fml}
  373. { 's :=
  374.   #1 'nameptr :=               % nameptr = 1;
  375.   s num.names$ 'numnames :=    % numnames = num.name$(s);
  376.   numnames 'namesleft :=
  377.     { namesleft #0 > }
  378.  
  379.     { s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't :=
  380.  
  381.       nameptr #1 >
  382.         { namesleft #1 >
  383.               { ", " * t * }
  384.                { numnames #2 >
  385.                     { "," * }
  386.                     'skip$
  387.                   if$
  388.                   t "others" =
  389.                         { " et~al." * }
  390. %                        { " and " * t * }
  391.                         { " \& " * t * }
  392.                       if$
  393.                 }
  394.                if$
  395.              }
  396.             't
  397.         if$
  398.         nameptr #1 + 'nameptr :=          % nameptr += 1;
  399.         namesleft #1 - 'namesleft :=      % namesleft =- 1;
  400.     }
  401.   while$
  402. }
  403.  
  404. FUNCTION {format.authors}
  405. { author empty$
  406.     { "" }
  407.     { author format.names }
  408.   if$
  409. }
  410.  
  411. FUNCTION {format.key}
  412. { empty$
  413.     { key field.or.null }
  414.     { "" }
  415.   if$
  416. }
  417.  
  418. FUNCTION {format.editors.fml}
  419. { editor empty$
  420.     { "" }
  421.     { editor format.names.fml
  422.       editor num.names$ #1 >
  423.     { " (Eds.)" * }
  424.     { " (Ed.)" * }
  425.       if$
  426.     }
  427.   if$
  428. }
  429.  
  430. FUNCTION {format.editors}
  431. { editor empty$
  432.     { "" }
  433.     { editor format.names
  434.       editor num.names$ #1 >
  435.     { " (Eds.)" * }
  436.     { " (Ed.)" * }
  437.       if$
  438.     }
  439.   if$
  440. }
  441.  
  442. FUNCTION {format.editors.dot}
  443. { editor empty$
  444.     { "" }
  445.     { editor format.names
  446.       editor num.names$ #1 >
  447.     { " (Eds.)." * }
  448.     { " (Ed.)." * }
  449.       if$
  450.     }
  451.   if$
  452. }
  453.  
  454. FUNCTION {format.title}
  455. { title empty$
  456.     { "" }
  457.     { title "t" change.case$ }
  458.   if$
  459. }
  460.  
  461. % Note that the APA style requres case changes
  462. % in article titles. The following does not
  463. % change cases. If you perfer it, uncomment the
  464. % following and comment out the above.
  465.  
  466. %FUNCTION {format.title}
  467. %{ title empty$
  468. %    { "" }
  469. %    { title }
  470. %  if$
  471. %}
  472.  
  473. FUNCTION {n.dashify}
  474. { 't :=
  475.   ""
  476.     { t empty$ not }
  477.     { t #1 #1 substring$ "-" =
  478.     { t #1 #2 substring$ "--" = not
  479.         { "--" *
  480.           t #2 global.max$ substring$ 't :=
  481.         }
  482.         {   { t #1 #1 substring$ "-" = }
  483.         { "-" *
  484.           t #2 global.max$ substring$ 't :=
  485.         }
  486.           while$
  487.         }
  488.       if$
  489.     }
  490.     { t #1 #1 substring$ *
  491.       t #2 global.max$ substring$ 't :=
  492.     }
  493.       if$
  494.     }
  495.   while$
  496. }
  497.  
  498. FUNCTION {format.btitle}
  499. { edition empty$
  500.   { title emphasize }
  501.   { title empty$
  502.     { title emphasize }
  503.     { "{\em " title * "\/} (" * edition * " ed.)" * "." * }
  504.     if$
  505.   }
  506.   if$
  507. }
  508.  
  509. FUNCTION {format.emphasize.booktitle}
  510. { edition empty$
  511.   { booktitle emphasize }
  512.   { booktitle empty$
  513.     { booktitle emphasize }
  514.     { "{\em " booktitle * "\/} (" * edition * " ed.)" * "." * }
  515.     if$
  516.   }
  517.   if$
  518. }
  519.  
  520. FUNCTION {tie.or.space.connect}
  521. { duplicate$ text.length$ #3 <
  522.     { "~" }
  523.     { " " }
  524.   if$
  525.   swap$ * *
  526. }
  527.  
  528. FUNCTION {either.or.check}
  529. { empty$
  530.     'pop$
  531.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  532.   if$
  533. }
  534.  
  535. FUNCTION {format.bvolume}
  536. { volume empty$
  537.     { "" }
  538.     { "volume" volume tie.or.space.connect
  539.       series empty$
  540.         'skip$
  541.         { " of " * series emphasize * }
  542.       if$
  543.       "volume and number" number either.or.check
  544.     }
  545.   if$
  546. }
  547.  
  548. FUNCTION {format.number.series}
  549. { volume empty$
  550.     { number empty$
  551.     { series field.or.null }
  552.     { output.state mid.sentence =
  553.         { "number" }
  554.         { "Number" }
  555.       if$
  556.       number tie.or.space.connect
  557.       series empty$
  558.         { "there's a number but no series in " cite$ * warning$ }
  559.         { " in " * series * }
  560.       if$
  561.     }
  562.       if$
  563.     }
  564.     { "" }
  565.   if$
  566. }
  567.  
  568. FUNCTION {format.edition}
  569. { edition empty$
  570.     { "" }
  571.     { output.state mid.sentence =
  572.         { edition "l" change.case$ " edition" * }
  573.         { edition "t" change.case$ " edition" * }
  574.       if$
  575.     }
  576.   if$
  577. }
  578.  
  579. INTEGERS { multiresult }
  580.  
  581. FUNCTION {multi.page.check}
  582. { 't :=
  583.   #0 'multiresult :=
  584.     { multiresult not
  585.       t empty$ not
  586.       and
  587.     }
  588.     { t #1 #1 substring$
  589.       duplicate$ "-" =
  590.       swap$ duplicate$ "," =
  591.       swap$ "+" =
  592.       or or
  593.     { #1 'multiresult := }
  594.     { t #2 global.max$ substring$ 't := }
  595.       if$
  596.     }
  597.   while$
  598.   multiresult
  599. }
  600.  
  601. FUNCTION {format.pages}
  602. { pages empty$
  603.   { "" }
  604.   { pages multi.page.check
  605. %    { "pages" pages n.dashify tie.or.space.connect }
  606. %    { "page" pages tie.or.space.connect }
  607.     { "(pp.\" pages n.dashify tie.or.space.connect }
  608.     { "(pp.\" pages tie.or.space.connect }
  609.     if$
  610.     ")." *
  611.   }
  612.   if$
  613. }
  614.  
  615. % By Young (and Spencer)
  616. FUNCTION {format.vol.num.pages}
  617. { number empty$
  618.     { volume empty$
  619.        'skip$
  620.        { "{\em " volume * "}" * }
  621. %       { "\underline{" volume * "}" * }
  622.       if$
  623.     }
  624.     { volume emphasize.space
  625.       number empty$
  626.        {"there's a number but no volume in " cite$ * warning$ }
  627.        { "(" number * ")" * * }
  628.       if$
  629.     }
  630.   if$
  631.   pages empty$
  632.     'skip$
  633.     { duplicate$ empty$
  634.       { pop$ format.pages }
  635.       { ", " * pages n.dashify * }
  636.       if$
  637.     }
  638.   if$
  639. }
  640.  
  641. FUNCTION {format.chapter.pages}
  642. { chapter empty$
  643.     'format.pages
  644.     { type empty$
  645.         { "chapter" }
  646.         { type "l" change.case$ }
  647.       if$
  648.       chapter tie.or.space.connect
  649.       pages empty$
  650.         'skip$
  651.         { ", " * format.pages * }
  652.       if$
  653.     }
  654.   if$
  655. }
  656.  
  657. FUNCTION {format.chapter.pages.incoll}
  658. { chapter empty$
  659.     'format.pages
  660.     { type empty$
  661.         { "chapter" }
  662.         { type "l" change.case$ }
  663.       if$
  664.       chapter tie.or.space.connect
  665.       pages empty$
  666.         'skip$
  667.         { " " * format.pages * }
  668.       if$
  669.     }
  670.   if$
  671. }
  672.  
  673. FUNCTION {format.in.ed.booktitle}
  674. { booktitle empty$
  675.   { "" }
  676.   { editor empty$
  677.     { "In " format.emphasize.booktitle * }
  678.     { "In " format.editors * ", " * format.emphasize.booktitle * }
  679.     if$
  680.   }
  681.   if$
  682. }
  683.  
  684. FUNCTION {format.in.ed.booktitle.incoll}
  685. { booktitle empty$
  686.   { "" }
  687.   { editor empty$
  688.     { "In " format.emphasize.booktitle * }
  689.     { "In " format.editors.fml * ", " * format.emphasize.booktitle * }
  690.     if$
  691.   }
  692.   if$
  693. }
  694.  
  695. FUNCTION {format.thesis.type}
  696. { type empty$
  697.     'skip$
  698.     { pop$
  699.       type "t" change.case$
  700.     }
  701.   if$
  702. }
  703.  
  704. FUNCTION {format.tr.number}
  705. { type empty$
  706.     { "Technical Report" }
  707.     'type
  708.   if$
  709.   number empty$
  710.     { "t" change.case$ }
  711.     { number tie.or.space.connect }
  712.   if$
  713. }
  714.  
  715. FUNCTION {format.article.crossref}
  716. { "In"
  717.   "\cite{" * crossref * "}" *
  718. }
  719.  
  720. FUNCTION {format.crossref.editor}
  721. { editor #1 "{vv~}{ll}" format.name$
  722.   editor num.names$ duplicate$
  723.   #2 >
  724.     { pop$ " et~al." * }
  725.     { #2 <
  726.     'skip$
  727.     { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  728.         { " et~al." * }
  729.         { " and " * editor #2 "{vv~}{ll}" format.name$ * }
  730.       if$
  731.     }
  732.       if$
  733.     }
  734.   if$
  735. }
  736.  
  737. FUNCTION {format.book.crossref}
  738. { volume empty$
  739.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  740.       "In "
  741.     }
  742.     { "Volume" volume tie.or.space.connect
  743.       " of " *
  744.     }
  745.   if$
  746.   editor empty$
  747.   editor field.or.null author field.or.null =
  748.   or
  749.     { key empty$
  750.     { series empty$
  751.         { "need editor, key, or series for " cite$ * " to crossref " *
  752.           crossref * warning$
  753.           "" *
  754.         }
  755.         { "{\em " * series * "\/}" * }
  756.       if$
  757.     }
  758.     { key * }
  759.       if$
  760.     }
  761.     { format.crossref.editor * }
  762.   if$
  763.   " \cite{" * crossref * "}" *
  764. }
  765.  
  766. FUNCTION {format.incoll.inproc.crossref}
  767. { "In"
  768.   " \cite{" * crossref * "}" *
  769. }
  770.  
  771. FUNCTION {article}
  772. { output.bibitem
  773.   format.authors 
  774.   "author" output.check
  775.   author format.key output          % added
  776.   output.year.check                 % added
  777.   new.block
  778.   format.title 
  779.   "title" output.check
  780.   new.block
  781.   crossref missing$
  782.     { journal emphasize "journal" output.check
  783.       format.vol.num.pages output
  784.     }
  785.     { format.article.crossref output.nonnull
  786.       format.pages output
  787.     }
  788.   if$
  789.   new.block
  790.   note output
  791.   fin.entry
  792. }
  793.  
  794. FUNCTION {book}
  795. { output.bibitem
  796.   author empty$
  797.     { format.editors.dot 
  798.       "author and editor" output.check }
  799.     { format.authors 
  800.       output.nonnull
  801.       crossref missing$
  802.         { "author and editor" editor either.or.check }
  803.         'skip$
  804.       if$
  805.     }
  806.   if$
  807.   output.year.check       % added
  808.   new.block
  809.   format.btitle 
  810.   "title" output.check
  811.   crossref missing$
  812.     { format.bvolume output
  813.       new.block
  814.       format.number.series output
  815.       new.sentence
  816.       address output
  817.       publisher "publisher" output.check.colon
  818.     }
  819.     { new.block
  820.       format.book.crossref output.nonnull
  821.     }
  822.   if$
  823. %  format.edition output
  824.   new.block
  825.   note output
  826.   fin.entry
  827. }
  828.  
  829. FUNCTION {booklet}
  830. { output.bibitem
  831.   format.authors output
  832.   author format.key output          % added
  833.   output.year.check                 % added
  834.   new.block
  835.   format.title 
  836.   "title" output.check
  837.   new.block
  838.   howpublished output
  839.   address output
  840.   new.block
  841.   note output
  842.   fin.entry
  843. }
  844.  
  845. FUNCTION {inbook}
  846. { output.bibitem
  847.   author empty$
  848.     { format.editors.dot 
  849.       "author and editor" output.check 
  850.     }
  851.     { format.authors output.nonnull
  852.       crossref missing$
  853.     { "author and editor" editor either.or.check }
  854.     'skip$
  855.       if$
  856.     }
  857.   if$
  858.   output.year.check                 % added
  859.   new.block
  860.   format.btitle 
  861.   "title" output.check
  862.   crossref missing$
  863.     { format.bvolume output
  864.       format.chapter.pages 
  865.       "chapter and pages" output.check
  866.       new.block
  867.       format.number.series output
  868.       new.sentence
  869.       address output
  870.       publisher 
  871.       "publisher" output.check.colon
  872.     }
  873.     { format.chapter.pages "chapter and pages" output.check
  874.       new.block
  875.       format.book.crossref output.nonnull
  876.     }
  877.   if$
  878. %  format.edition output
  879.   new.block
  880.   note output
  881.   fin.entry
  882. }
  883.  
  884. FUNCTION {incollection}
  885. { output.bibitem
  886.   format.authors
  887.   "author" output.check
  888.   author format.key output       % added
  889.   output.year.check              % added
  890.   new.block
  891.   format.title 
  892.   "title" output.check
  893.   new.block
  894.   crossref missing$
  895.   { format.in.ed.booktitle.incoll 
  896.     "booktitle" output.check.colon
  897.     format.bvolume output
  898.     format.number.series output
  899.     format.chapter.pages special.output
  900.     new.sentence
  901.     address output
  902.     publisher "publisher" output.check.colon
  903.   }
  904.   { format.incoll.inproc.crossref 
  905.     output.nonnull
  906.     format.chapter.pages output
  907.   }
  908.   if$
  909.   new.block
  910.   note output
  911.   fin.entry
  912. }
  913.  
  914. FUNCTION {inproceedings}
  915. { output.bibitem
  916.   format.authors 
  917.   "author" output.check
  918.   author format.key output            % added
  919.   output.year.check                   % added
  920.   new.block
  921.   format.title 
  922.   "title" output.check
  923.   new.block
  924.   crossref missing$
  925.     { format.in.ed.booktitle 
  926.       "booktitle" output.check
  927.       format.bvolume output
  928.       format.number.series output
  929.       format.pages output
  930.       address output
  931.       new.sentence
  932.       organization output
  933.       publisher output
  934.     }
  935.     { format.incoll.inproc.crossref output.nonnull
  936.       format.pages output
  937.     }
  938.   if$
  939.   new.block
  940.   note output
  941.   fin.entry
  942. }
  943.  
  944. FUNCTION {conference} { inproceedings }
  945.  
  946. FUNCTION {manual}
  947. { output.bibitem
  948.   format.authors output
  949.   author format.key output          % added
  950.   output.year.check                 % added
  951.   new.block
  952.   format.btitle 
  953.   "title" output.check
  954.   organization address new.block.checkb
  955. % Reversed the order of "address" and "organization", added the ":".
  956.   address output
  957.   organization "organization" output.check.colon
  958. %  address output
  959. %  ":" output
  960. %  organization output
  961. %  format.edition output
  962.   new.block
  963.   note output
  964.   fin.entry
  965. }
  966.  
  967. FUNCTION {mastersthesis}
  968. { output.bibitem
  969.   format.authors 
  970.   "author" output.check
  971.   author format.key output          % added
  972.   output.year.check                 % added
  973.   new.block
  974.   format.title 
  975.   "title" output.check
  976.   new.block
  977.   "Master's thesis" format.thesis.type output.nonnull
  978.   school "school" output.check
  979.   address output
  980.   new.block
  981.   note output
  982.   fin.entry
  983. }
  984.  
  985. FUNCTION {misc}
  986. { output.bibitem
  987.   format.authors output
  988.   author format.key output            % added
  989.   output.year.check                   % added
  990.   title howpublished new.block.checkb
  991.   format.title output
  992.   new.block
  993.   howpublished output
  994.   new.block
  995.   note output
  996.   fin.entry
  997. }
  998.  
  999. FUNCTION {phdthesis}
  1000. { output.bibitem
  1001.   format.authors 
  1002.   "author" output.check
  1003.   author format.key output            % added
  1004.   output.year.check                   % added
  1005.   new.block
  1006.   format.btitle 
  1007.   "title" output.check
  1008.   new.block
  1009.   "PhD thesis" format.thesis.type output.nonnull
  1010.   school "school" output.check
  1011.   address output
  1012.   new.block
  1013.   note output
  1014.   fin.entry
  1015. }
  1016.  
  1017. FUNCTION {proceedings}
  1018. { output.bibitem
  1019.   editor empty$
  1020.     { organization output }
  1021.     { format.editors.dot output.nonnull }
  1022.   if$
  1023.   author format.key output             % added
  1024.   output.year.check                    % added
  1025.   new.block
  1026.   format.btitle 
  1027.   "title" output.check
  1028.   format.bvolume output
  1029.   format.number.series output
  1030.   address output
  1031.   new.sentence
  1032.   organization output
  1033.   publisher output
  1034.   new.block
  1035.   note output
  1036.   fin.entry
  1037. }
  1038.  
  1039. FUNCTION {techreport}
  1040. { output.bibitem
  1041.   format.authors 
  1042.   "author" output.check
  1043.   author format.key output             % added
  1044.   output.year.check                    % added
  1045.   new.block
  1046.   format.title 
  1047.   "title" output.check
  1048.   new.block
  1049.   format.tr.number output.nonnull
  1050.   institution 
  1051.   "institution" output.check
  1052.   address output
  1053.   new.block
  1054.   note output
  1055.   fin.entry
  1056. }
  1057.  
  1058. FUNCTION {unpublished}
  1059. { output.bibitem
  1060.   format.authors 
  1061.   "author" output.check
  1062.   author format.key output              % added
  1063.   output.year.check                      % added
  1064.   new.block
  1065.   format.title 
  1066.   "title" output.check
  1067.   new.block
  1068.   note "note" output.check
  1069.   fin.entry
  1070. }
  1071.  
  1072. FUNCTION {default.type} { misc }
  1073.  
  1074. MACRO {jan} {"January"}
  1075.  
  1076. MACRO {feb} {"February"}
  1077.  
  1078. MACRO {mar} {"March"}
  1079.  
  1080. MACRO {apr} {"April"}
  1081.  
  1082. MACRO {may} {"May"}
  1083.  
  1084. MACRO {jun} {"June"}
  1085.  
  1086. MACRO {jul} {"July"}
  1087.  
  1088. MACRO {aug} {"August"}
  1089.  
  1090. MACRO {sep} {"September"}
  1091.  
  1092. MACRO {oct} {"October"}
  1093.  
  1094. MACRO {nov} {"November"}
  1095.  
  1096. MACRO {dec} {"December"}
  1097.  
  1098. MACRO {acmcs} {"ACM Computing Surveys"}
  1099.  
  1100. MACRO {acta} {"Acta Informatica"}
  1101.  
  1102. MACRO {ai} {"Artificial Intelligence"}
  1103.  
  1104. MACRO {cacm} {"Communications of the ACM"}
  1105.  
  1106. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  1107.  
  1108. MACRO {ibmsj} {"IBM Systems Journal"}
  1109.  
  1110. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  1111.  
  1112. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  1113.  
  1114. MACRO {ieeetcad}
  1115.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  1116.  
  1117. MACRO {ipl} {"Information Processing Letters"}
  1118.  
  1119. MACRO {jacm} {"Journal of the ACM"}
  1120.  
  1121. MACRO {jcss} {"Journal of Computer and System Sciences"}
  1122.  
  1123. MACRO {scp} {"Science of Computer Programming"}
  1124.  
  1125. MACRO {sicomp} {"SIAM Journal on Computing"}
  1126.  
  1127. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  1128.  
  1129. MACRO {tods} {"ACM Transactions on Database Systems"}
  1130.  
  1131. MACRO {tog} {"ACM Transactions on Graphics"}
  1132.  
  1133. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  1134.  
  1135. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  1136.  
  1137. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  1138.  
  1139. MACRO {tcs} {"Theoretical Computer Science"}
  1140.  
  1141. READ
  1142.  
  1143. FUNCTION {sortify}
  1144. { purify$
  1145.   "l" change.case$
  1146. }
  1147.  
  1148. INTEGERS { len }
  1149.  
  1150. FUNCTION {chop.word}
  1151. { 's :=
  1152.   'len :=
  1153.   s #1 len substring$ =
  1154.     { s len #1 + global.max$ substring$ }
  1155.     's
  1156.   if$
  1157. }
  1158.  
  1159. INTEGERS { fullptr numfull fullsleft }
  1160.  
  1161. STRINGS { u1 u2 }
  1162.  
  1163. FUNCTION {my.full.label}
  1164. % Initialize 'u1','u2','s'.
  1165.   "" 'u1 :=                                       
  1166.   "" 'u2 :=                     
  1167.   's :=                      
  1168.  
  1169. % Initialize 'fullptr','numfull','fullsleft'.
  1170.   #1 'fullptr :=                         
  1171.   s num.names$ 'numfull :=   
  1172.   numfull 'fullsleft :=          
  1173.  
  1174. % enter the while loop which generates the first-citation information.
  1175. % while we have names left, 
  1176. %     format the next name
  1177. %   if this is the next-to-last name, tack the ampersand on the end
  1178. %   else if this isn't the last name, tack the comma on the end.
  1179. %   concatenate the next name onto the first-citation string.
  1180. %   update the counters.
  1181.  
  1182.   { fullsleft #0 > }
  1183.   { s fullptr "{vv~}{ll}" format.name$ 'u1 :=  
  1184.      fullsleft #2 =
  1185.        { u1 " \& " * 'u1 := }
  1186.       { fullsleft #2 > 
  1187.            { u1 ", " * 'u1 := }
  1188.            'skip$
  1189.          if$
  1190.         }
  1191.     if$
  1192.      u2 u1 * 'u2 :=
  1193.      fullptr #1 + 'fullptr :=         
  1194.      fullsleft #1 - 'fullsleft :=  
  1195.   }
  1196.   while$
  1197.  
  1198. % push 'u2' onto the stack -- our first-citation information.
  1199.   u2        
  1200. }
  1201.  
  1202. FUNCTION {format.lab.names}
  1203. { 's :=                             
  1204.   s #1 "{vv~}{ll}" format.name$        
  1205.   s num.names$ duplicate$
  1206.   #2 >                                
  1207.      { pop$ " et~al." * }            
  1208.      { #2 <
  1209.           'skip$
  1210.           { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  1211.                 { "et~al. " * }
  1212. %               { " and " * s #2 "{vv~}{ll}" format.name$ * }
  1213.                 { " \& " * s #2 "{vv~}{ll}" format.name$ * }
  1214.              if$
  1215.             }
  1216.        if$
  1217.      }
  1218.   if$
  1219. }
  1220.  
  1221. FUNCTION {author.key.label}
  1222. { author empty$
  1223.     { key empty$
  1224.           { cite$ #1 #3 substring$ }
  1225.          'key
  1226.       if$
  1227.     }
  1228.     { author format.lab.names }
  1229.   if$
  1230. }
  1231.  
  1232. FUNCTION {editor.key.label}
  1233. { editor empty$
  1234.     { key empty$
  1235.           { cite$ #1 #3 substring$ }
  1236.           'key
  1237.         if$
  1238.      }
  1239.      { editor format.lab.names }
  1240.   if$
  1241. }
  1242.  
  1243. FUNCTION {author.editor.key.label}
  1244. { author empty$
  1245.     { editor empty$
  1246.           { key empty$
  1247.                { cite$ #1 #3 substring$ }
  1248.              'key
  1249.            if$
  1250.          }
  1251.           { editor format.lab.names }
  1252.       if$
  1253.     }
  1254.     { author format.lab.names }
  1255.   if$
  1256. }
  1257.  
  1258. FUNCTION {calc.label}
  1259. { type$ "book" =
  1260.   type$ "inbook" =
  1261.   or
  1262.     'author.editor.key.label
  1263.     { type$ "proceedings" =
  1264.           'editor.key.label
  1265.           'author.key.label
  1266.         if$
  1267.     }
  1268.   if$
  1269.   duplicate$    
  1270.  
  1271.   author my.full.label  % generate the first-citation information.
  1272.  
  1273.   "\protect\citeauthoryear{" swap$ * "}{" * swap$ * "}{" *
  1274.   year field.or.null purify$ #-1 #4 substring$ *  
  1275.   'label :=
  1276.   year field.or.null purify$ #-1 #4 substring$ *
  1277.   sortify 'sort.label :=
  1278. }
  1279.  
  1280. FUNCTION {sort.format.names}
  1281. { 's :=
  1282.   #1 'nameptr :=
  1283.   ""
  1284.   s num.names$ 'numnames :=
  1285.   numnames 'namesleft :=
  1286.     { namesleft #0 > }
  1287.     { nameptr #1 >
  1288.           { "   " * }
  1289.          'skip$
  1290.       if$
  1291.       s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ 't :=
  1292.       nameptr numnames = t "others" = and
  1293.           { "et al" * }
  1294.           { t sortify * }
  1295.       if$
  1296.       nameptr #1 + 'nameptr :=
  1297.       namesleft #1 - 'namesleft :=
  1298.     }
  1299.   while$
  1300. }
  1301.  
  1302. FUNCTION {sort.format.title}
  1303. { 't :=
  1304.   "A " #2
  1305.     "An " #3
  1306.       "The " #4 t chop.word
  1307.     chop.word
  1308.   chop.word
  1309.   sortify
  1310.   #1 global.max$ substring$
  1311. }
  1312.  
  1313. FUNCTION {author.sort}
  1314. { author empty$
  1315.     { key empty$
  1316.           { "to sort, need author or key in " cite$ * warning$
  1317.               ""
  1318.          }
  1319.          { key sortify }
  1320.       if$
  1321.     }
  1322.     { author sort.format.names }
  1323.   if$
  1324. }
  1325.  
  1326. FUNCTION {editor.sort}
  1327. { editor empty$
  1328.     { key empty$
  1329.          { "to sort, need editor or key in " cite$ * warning$
  1330.            ""
  1331.          }
  1332.          { key sortify }
  1333.       if$
  1334.     }
  1335.     { editor sort.format.names }
  1336.   if$
  1337. }
  1338.  
  1339. FUNCTION {author.editor.sort}
  1340. { author empty$
  1341.     { editor empty$
  1342.          { key empty$
  1343.              { "to sort, need author, editor, or key in " cite$ * warning$
  1344.                ""
  1345.              }
  1346.              { key sortify }
  1347.            if$
  1348.          }
  1349.          { editor sort.format.names }
  1350.       if$
  1351.    }
  1352.    { author sort.format.names }
  1353.   if$
  1354. }
  1355.  
  1356. FUNCTION {presort}
  1357. { calc.label
  1358.   label sortify
  1359.   "    "
  1360.   *
  1361.   type$ "book" =
  1362.   type$ "inbook" =
  1363.   or
  1364.     'author.editor.sort
  1365.     { type$ "proceedings" =
  1366.           'editor.sort
  1367.           'author.sort
  1368.       if$
  1369.     }
  1370.   if$
  1371.   #1 entry.max$ substring$        % added for newapa
  1372.   'sort.label :=                  % added for newapa
  1373.   sort.label                      % added for newapa
  1374.   *
  1375.   "    "
  1376.   *
  1377.   title field.or.null
  1378.   sort.format.title
  1379.   *
  1380.   #1 entry.max$ substring$
  1381.   'sort.key$ :=
  1382. }
  1383.  
  1384. ITERATE {presort}
  1385.  
  1386. SORT             % by label, sort.label, title --- for final label calculation
  1387.  
  1388. STRINGS { last.label next.extra }
  1389.  
  1390. INTEGERS { last.extra.num }
  1391.  
  1392. FUNCTION {initialize.extra.label.stuff}
  1393. { #0 int.to.chr$ 'last.label :=
  1394.   "" 'next.extra :=
  1395.   #0 'last.extra.num :=
  1396. }
  1397.  
  1398. FUNCTION {forward.pass}
  1399. { last.label label =
  1400.      { last.extra.num #1 + 'last.extra.num :=
  1401.        last.extra.num int.to.chr$ 'extra.label :=
  1402.      }
  1403.      { "a" chr.to.int$ 'last.extra.num :=
  1404.        "" 'extra.label :=
  1405.        label 'last.label :=
  1406.     }
  1407.   if$
  1408. }
  1409.  
  1410. FUNCTION {reverse.pass}
  1411. { next.extra "b" =
  1412.     { "a" 'extra.label := }
  1413.      'skip$
  1414.   if$
  1415.   label extra.label * "}" * 'label :=   
  1416.   extra.label 'next.extra :=
  1417. }
  1418.  
  1419. EXECUTE {initialize.extra.label.stuff}
  1420.  
  1421. ITERATE {forward.pass}
  1422.  
  1423. REVERSE {reverse.pass}
  1424.  
  1425. FUNCTION {bib.sort.order}
  1426. { sort.label
  1427.   "    "
  1428.   *
  1429.   year field.or.null sortify
  1430.   *
  1431.   "    "
  1432.   *
  1433.   title field.or.null
  1434.   sort.format.title
  1435.   *
  1436.   #1 entry.max$ substring$
  1437.   'sort.key$ :=
  1438. }
  1439.  
  1440. ITERATE {bib.sort.order}
  1441.  
  1442. SORT             % by sort.label, year, title --- giving final bib. order.
  1443.  
  1444. FUNCTION {begin.bib}
  1445.  
  1446. { preamble$ empty$
  1447.     'skip$
  1448.     { preamble$ write$ newline$ }
  1449.   if$
  1450.   "\begin{thebibliography}{}" write$ newline$
  1451. }
  1452.  
  1453.  
  1454. EXECUTE {begin.bib}
  1455.  
  1456. EXECUTE {init.state.consts}
  1457.  
  1458. ITERATE {call.type$}
  1459.  
  1460. FUNCTION {end.bib}
  1461. { newline$
  1462.   "\end{thebibliography}" write$ newline$
  1463. }
  1464.  
  1465. EXECUTE {end.bib}
  1466.  
  1467.  
  1468.